package Classes.GameViews.ViewPanels
{
	import Classes.GameUtils.GU_Sound;
	import Classes.GameViews.ViewScenes.VS_Main;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.system.ApplicationDomain;

	public class VP_TextWinPanel extends ViewPanel
	{
		private static var _instance:VP_TextWinPanel;
		private var _interfaceUI:Sprite;
		private var dobj:DisplayObject;
		public var buttonFlage:String="";
		public function VP_TextWinPanel()
		{
			this.init();
		}
		
		private function init():void
		{
			this._interfaceUI=new (ApplicationDomain.currentDomain.getDefinition("TextTips_v") as Class);
			dobj=this.addChild(this._interfaceUI);
			this.addListener();
		}
		
		private function addListener():void
		{
			this.addEventListener("customCallBack",customHandler);
			this.addEventListener("close",closeHandler);
		}
		
		private function customHandler(e:Event):void
		{
			buttonFlage="zdy";
			if(null!=_callBackFun)this._callBackFun();
			
			GU_Sound.instance.playCommSound("Button_Pressed");
			this.closeWin(false);
		}
		
		public function closeHandler(e:Event):void
		{
			this.closeWin();
		}
			
		private var _callBackFun:Function;
		/**
		 * 打开文字提示普弹框
		 */	
		public function openTextWindon(title:String="",context:String="",callFun:Function=null):void
		{
			this.controlCloseBtn(true);
			this._interfaceUI["setWinTxt"](title,context);
			this._callBackFun=callFun;
			this.openAt(VS_Main.instance,true);
			this.toCenter();
		}
		
		/**
		 *关闭界面 
		 * 
		 */		
		public function closeWin(sound:Boolean=true):void
		{
			this.close(sound);
		}
		
		
		
		/**
		 * 控制关闭按钮的显示 
		 * @param visable
		 * 
		 */		
		public function controlCloseBtn(visable:Boolean):void
		{
			this._interfaceUI["controlCloseBtnVisable"](visable);
		}
		
		public static function get instance():VP_TextWinPanel
		{
			if(!_instance)_instance=new VP_TextWinPanel();
			return _instance;
		}
		
		public function get interfaceUI():Sprite
		{
			return _interfaceUI;
		}
	}
}